<?php
/**************************** SERVICE INITIALIZATION BEGINS ****************************/
require_once("../../config.php");
require_once(ML_ROOT."/service-admin.php"); on_users_edit();

$user = isset($view_data[Protocol::USER]) ? $view_data[Protocol::USER] : NULL;
/***************************** SERVICE INITIALIZATION ENDS *****************************/
?>

<?php
/********************************* HTML CONTENT BEGINS *********************************/
require_once(ML_INCLUDE."/admin-header.php");
?>
	<h1>Users Edit</h1>
	<form action="<?=url("/admin/users-edit.php")?>" method="post" autocomplete="on">
	<table>
		<?php if (isset($user[Protocol::ID])) :?>
		<tr>
			<td><label for="id">id</label></td>
			<td><input name="<?=Protocol::ID?>" id="id" type="id" value="<?=$user[Protocol::ID]?>" readonly /></td>
		</tr>
		<?php endif ?>
		<?php if (isset($user[Protocol::IS_MODEL])) :?>
		<tr>
			<td><label for="is_model">is_model</label></td>
			<td>
				<input name="<?=Protocol::IS_MODEL?>"
					id="is_model" type="text" value="<?=$user[Protocol::IS_MODEL] ? "YES" : "NO"?>" readonly />
			</td>
		</tr>
		<?php endif ?>
		<tr>
			<td><label for="email">email</label></td>
			<?php if (isset($user[Protocol::EMAIL])) :?>
			<td><input name="<?=Protocol::EMAIL?>" id="email" type="email" value="<?=$user[Protocol::EMAIL]?>" /></td>
			<?php else :?>
			<td><input name="<?=Protocol::EMAIL?>" id="email" type="email" autofocus /></td>
			<?php endif ?>
		</tr>
		<tr>
			<td><label for="password">password</label></td>
			<?php if (isset($user[Protocol::PASSWORD])) :?>
			<td><input name="<?=Protocol::PASSWORD?>" id="password" type="password" value="<?=$user[Protocol::PASSWORD]?>" /></td>
			<?php else :?>
			<td><input name="<?=Protocol::PASSWORD?>" id="password" type="password" /></td>
			<?php endif ?>
		</tr>
		<tr>
			<td><label for="conrimation">confirmation</label></td>
			<td><input name="conrimation" id="conrimation" type="password" /></td>
		</tr>
		<tr>
			<td><label for="name">name</label></td>
			<?php if (isset($user[Protocol::NAME])) :?>
			<td><input name="<?=Protocol::NAME?>" id="name" type="text" value="<?=$user[Protocol::NAME]?>" /></td>
			<?php else :?>
			<td><input name="<?=Protocol::NAME?>" id="name" type="text" /></td>
			<?php endif ?>
		</tr>
		<tr>
			<td><label for="description">description</label></td>
			<?php if (isset($user[Protocol::DESCRIPTION])) :?>
			<td><textarea name="<?=Protocol::DESCRIPTION?>" id="description"><?=$user[Protocol::DESCRIPTION]?></textarea></td>
			<?php else :?>
			<td><textarea name="<?=Protocol::DESCRIPTION?>" id="description"></textarea></td>
			<?php endif ?>
		</tr>
		<?php if (isset($user[Protocol::VIEWS])) :?>
		<tr>
			<td><label for="views">views</label></td>
			<td><input name="<?=Protocol::VIEWS?>" id="views" type="number" value="<?=$user[Protocol::VIEWS]?>" /></td>
		</tr>
		<?php endif ?>
		<?php if (isset($user[Protocol::LIKES])) :?>
		<tr>
			<td><label for="likes">likes</label></td>
			<td><input name="<?=Protocol::LIKES?>" id="likes" type="number" value="<?=$user[Protocol::LIKES]?>" /></td>
		</tr>
		<?php endif ?>
		<tr>
			<td colspan="2"><button type="submit">Confirm</button></td>
		</tr>
		<?php if (isset($user)) :?>
		<tr>
			<td colspan="2"><a href="<?=url("/admin/models-edit.php?user_id=".$user[Protocol::ID])?>">Model Profile</a></td>
		</tr>
		<?php endif ?>
	</table>
	</form>
<?php
require_once(ML_INCLUDE."/admin-footer.php");
/********************************** HTML CONTENT ENDS **********************************/
?>